All Functions of Week 10

lm

{stats}

Fit linear models using least squares

factor

{base}

Create a factor

coeftest

{lmtest}

Inference for Estimated Coefficients

as.numeric

{base}

Coerce a vector to numeric

mutate

{dplyr}

Create new variables

margin

{GGPLOT2}

Set margins around plot elements (used inside theme elements)

vcov

{stats}

Extract the variance-covariance matrix from a fitted model

geom_hline

{GGPLOT2}

Add a horizontal line in GGPLOT2

geom_point

{GGPLOT2}

Generates a scatter plot

vcovHC

{sandwich}

Heteroscedasticity-consistent estimation of the covariance matrix of the coefficient estimates

expression

{base}

Used in plots to add symbols to axes

round

{base}

Rounds numbers

filter

{dplyr}

Filter out rows of a data frame according to logical vector

factor

{base}

Create factor variables

with

{base}

evaluate expression in the context of a data frame

resid

{stats}

Extracts model residuals from objects returned by modeling functions

labs

{GGPLOT2}

Customise labels in GGPLOT2

diag

{base}

Extract or construct diagonal elements or matrices

DescTools

{DescTools}

A package of miscellaneous functions for descriptive statistics and basic data analysis

element_blank

{GGPLOT2}

This theme element draws nothing, and assigns no space

library

{base}

Load an R package

hatvalues

{stats}

Extract leverage (hat) values from a fitted model

table

{base}

Obtain frequency table of a variable/cross-tabulation of two variables

resettest

{lmtest}

Ramsey’s RESET test for functional form of a regression model

sample_frac

{dplyr}

Sample a fraction of observations from a data frame

recode

{dplyr}

Recode a variable

element_text

{GGPLOT2}

Customise text in GGPLOT2

theme_minimal

{GGPLOT2}

A minimalistic theme with no background annotations

read.csv

{utils}

Read a csv file to data frame. Specify stringsAsFactors = FALSE to keep all string columns as characters

theme_classic

{GGPLOT2}

A minimalistic theme with no gridlines

setwd

{base}

Set Working Directory

ggplot

{GGPLOT2}

Create a ggplot graph

replace

{base}

Replace elements in a vector

correlation_matrix

{corrtable}

Create a formatted correlation matrix of variables

summary

{base}

Obtain summary statistics or detailed regression output

abline

{graphics}

Add a straight line to a plot (by intercept/slope, or horizontal/vertical)

knit_hooks

{knitr}

Get or set knitr hook functions for customising output

theme

{GGPLOT2}

Customize ggplot themes

stat_smooth

{GGPLOT2}

Add a smoothed conditional mean (the stat underlying geom_smooth)

bptest

{lmtest}

Breusch-Pagan Test for Homoscedasticity

as.character

{base}

Coerce a vector to character

plot

{graphics}

Generic function from base R to produce a plot

max

{base}

Get maximum of a vector

vif

{car}

Calculate Variance Inflation Factor

read_csv

{readr}

Read CSV files

pchisq

{stats}

Cumulative distribution function for chi-squared distribution

write.csv

{utils}

write a csv file to a data frame

aes

{GGPLOT2}

Construct aesthetic mapping of a ggplot graph

is.na

{base}

Check if a value is NA/elements of vector are NA

nobs

{stats}

Return the number of observations in a model object

poly

{stats}

Compute orthogonal polynomials (used for polynomial regression)

set.seed

{base}

Initialise a pseudorandom number generator.

data.frame

{base}

Create a data.frame from vectors

c

{base}

Combine values/vectors into a vector

The end!